<%@ include file="../import_page.jsp" %>
<%
	//login checking
	if(!loginedChecking(session, UsersType.staff)) {
		//user don't login
		//redirect to home page
		response.sendRedirect(URL_HOMEPAGE);
		return;
	}
	
	//select unit check
	if(!selectUnitCheck(session)) {
		//if user didn't select an Unit
		//redirtect to select page
		response.sendRedirect(URL_SELECT_UNIT);
		return;
	}
	
	Users loginUser = (Users)session.getAttribute(SESSION_LOGIN_USER);
	Units selectUnit = (Units)session.getAttribute(SESSION_SELECT_UNIT);
	String errMsg = null;
	
	ArrayList<AssignmentCollector> listAss = null;
	//get assignment
	try {
		AssignmentsControl assCon = new AssignmentsControl();
		listAss = assCon.getAssignments(selectUnit.getId());
		assCon.closeDBConnection();
	} catch (Exception err) {
		errMsg = err.toString();
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>Uni-Learn - Assignment Select</title>
<style type="text/css">
<!--
.style1 {	font-size: large;
	font-weight: bold;
}
.style2 {font-size: xx-large}
-->
</style>
</head>

<body>
<table width="100%" border="1" align="left" bordercolor="#CCCCCC" bgcolor="#00FF99">
  <tr>
    <th colspan="7"><div align="center"><span class="style1">Staff Assignment Selection </span></div></th>
  </tr>
  <tr rowspan="2">
  	<th rowspan="2">Name</th>
  	<th rowspan="2">Group</th>
  	<th rowspan="2">Deadline</th>
  	<th rowspan="2">Full Mark</th>
  	<th colspan="3">Status</th>
  </tr>
  <tr>
	<th>Submission</th>
  	<th>Marking</th>
  	<th>Modify</th>
  </tr>
<%
	if(listAss != null) {
		Iterator<AssignmentCollector> laI = listAss.iterator();

		while(laI.hasNext()) {
			AssignmentCollector ac = laI.next();
%>
   <tr>
    <td height="63">
    	<span class="style2"><a href="#"><%= ac.getName() %></a></span>
    </td>
    <td><%= (ac.getGroupSize() < 2 ? "Individual" : ("Group (" + ac.getGroupSize()+ ")")) %></td>
    <td><%= formatDateTime(ac.getDeadline()) %></td>
    <td><%= ac.getFullMark().toString() %></td>
    <td><%= ac.isSubmission() ? "Yes" : "No" %></td>
<%			if(ac.isMarking()) { %>
	<td><a href="<%= addParmeterToUrl(URL_VIEW_SUBMITED, PAR_ASSIGNMENT_ID, Integer.toString(ac.getId())) %>">Yes</a></td>
<%			} else { %>
	<td>No</td>
<%			} %>
    <td><a href="<%= addParmeterToUrl(URL_UPDATE_ASSIGNMENT, PAR_ASSIGNMENT_ID, Integer.toString(ac.getId()))%>">Modify</a></td>
  </tr>
  <tr>
    	<td colspan="7">
    	<table width="90%" border="1" bordercolor="#CCCCCC" style="margin: 0 5%;">
    		<tr>
    			<td>Information:</td>
    			<td><%= muiliteLineString(ac.getInfo()) %></td>
    		</tr>
    		<tr>
    			<td>Material:</td>
    			<td>
    			<table width="100%" border="1" >
    				<tr>
    					<td>
    					Material 1<br />Material 1 information<br /><a href="#">Download: Material 1</a>
    					</td>
    				</tr>
    				<tr>
    					<td>Material 1<br />Material 1 information<br /><a href="#">Download: Material 1</a></td>
    				</tr>
    			</table>
    			</td>
    		</tr>
    	</table>
    	</td>
  
  </tr>
<%
		}
	}
%>
</table>
</body>
</html>
